<template>
	<view class="need-box">
		<view class="need-list-box">
			<view class="need-list-box_title">
				<text>车商同行{{needInfo.encry}}求购</text>

			</view>
			<view>
				<uv-text :text="needInfo.brand"></uv-text>
				<uv-text :size="13" :text="`车源地要求：${ needInfo.location}`" margin="5px 0 0 0"></uv-text>

			</view>
			<view class="need-list-box_other">
				<uv-text :text="needInfo.other" :size="13" type="info"></uv-text>
			</view>
			<uv-line />
			<view class="need-list-box_foot">
				<view class="time">
					<text> {{needInfo.time}} 发布</text>
				</view>

			</view>
		</view>

		<fy-user-desc :userInfo="userInfo"></fy-user-desc>
		<fy-user-nav :user-info="userInfo"></fy-user-nav>
	</view>
</template>

<script>
	import { queryNeedBuyInfo, queryUserInfo } from '@/utils/http.js'
	import { encryptphone, timespantoYMD } from '@/common/tools.js'
	import baseconfig from '@/config.js'
	export default {
		data() {
			return {
				needid: 0,
				urlparm: {},
				needInfo: {},
				userInfo:{}
			}
		},
		onLoad(option) {
			this.needid = option.id
			this.urlparm = option
			this.fetchData()
			this.fetchUser()
		},
		methods: {
			fetchUser() {
				queryUserInfo(this.urlparm.userid).then(res => {
					const { data } = res
					data.userimgsrc = data.imgsrc ? baseconfig.api_url + data.imgsrc : ''
					var t = data.ipplace.split(' ')
					data.area = t[2]
					this.userInfo = data
				})
			},
			fetchData() {
				queryNeedBuyInfo(this.urlparm.needid).then(res => {
					const { data } = res
					data.time = timespantoYMD(data.createtime)
					data.encry = encryptphone(data.phone)
					this.needInfo = data
				})
			}
		}
	}
</script>